class Animation < Sketch3D
  def container
    super do
      block do
        pointLight(0.0, 0.8, 1.0, 0.0, 20.0, 200.0)
        pointLight(0.0, 0.0, 1.0, 40.0, 200.0, 600.0)
        ambientLight(0.0, 0.0, 0.1, -2.0, -20.0, 8.0)
        ambientLight(0.0, 0.0, 0.1, 200.0, -100.0, 18.0)
        #pointLight(0.0, 0.3, 0.5, 1.0, 8.0, 2.0)
        background 0
        noStroke
      end

      group do
        block do
          if @sketch.keys != {}
            #puts @sketch.key.inspect
            @stroke = Blue if @sketch.keys['b']
            @stroke = Red if @sketch.keys['r']
            @stroke = Green if @sketch.keys['g']

            @rx += 0.05 if @sketch.keys['-']
            @rx -= 0.05 if @sketch.keys['=']
          end
          @rz = pi_pulse(2000)
        end
        box(:ty => 0.6, :fill => Green)  do
          block :when => lambda { current_frame % 3 == 1 } do
            @ty = 1 + Math::sin(current_frame / 10.0) / 10.0
            @rz = Math::sin(current_frame / 5.0)
            @rx = Math::sin(current_frame / 30.0)
          end
          cycle 60, :bounce => true do
            @tx = -1 + cycle.to_f / 30.0
          end
          cycle 20 do
            @x = @y = @z = 0.2 + cycle / 30.0
          end
          axes
        end
        box(:ty => -0.6, :fill => Yellow) do
          cycle 10 do
            @fill.value = 0.5 + cycle / 20.0
            @tx = cycle.to_f / 100.0 * -1
          end
          block  do
            @fill.alpha = Math::sin(current_frame / 20.0).abs
          end
          axes
        end
      end
    end
  end
end
